package com.gitee.jmash.oidc.client.oauth;

import jakarta.ws.rs.core.Response;

/**
 * Restful Client Exception.
 */
public class RestClientException extends RuntimeException {

  private static final long serialVersionUID = 1L;

  private int status;

  private String reason;

  private String errors;

  /**
   * Response Create.
   */
  public RestClientException(Response res) {
    status = res.getStatus();
    reason = res.getStatusInfo().getReasonPhrase();
    if (res.getStatus() != 200) {
      errors = res.readEntity(String.class);
    }
  }


  public RestClientException(int status, String reason) {
    super();
    this.status = status;
    this.reason = reason;
  }


  public int getStatus() {
    return status;
  }

  public String getReason() {
    return reason;
  }

  public String getErrors() {
    return errors;
  }

  @Override
  public String toString() {
    return "RestClientException [status=" + status + ", reason=" + reason + ", errors=" + errors
        + "]";
  }
}
